import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Anagrams {

	public static final String IS_ANAGRAM = "The strings are anagrams";
	public static final String IS_NOT_ANAGRAM = "The strings are not anagrams";
	private static String inputStringOne;
	private static String inputStringTwo;
	private static ArrayList<Character> List_Of_Array_One = new ArrayList<Character>();
	private static ArrayList<Character> List_Of_Array_Two = new ArrayList<Character>();
	
	public static void main(String[] args) {
		readDataFromConsole();
		convertStringsToArrays();
		if (stringsAreAngram(List_Of_Array_One, List_Of_Array_Two)){
			System.out.println(IS_ANAGRAM);
		}
		else {
			System.out.println(IS_NOT_ANAGRAM);
		}
	}	
		
		
		
	private static void readDataFromConsole(){
		Scanner input = new Scanner(System.in);
		inputStringOne = input.nextLine().toUpperCase();
		inputStringTwo = input.nextLine().toUpperCase();
	} 		
	
	private static void convertStringsToArrays() {
		char[] charArrayOne = inputStringOne.toCharArray();
		char[] charArrayTwo = inputStringTwo.toCharArray();

		for (int i = 0; i < charArrayOne.length; i++){
			if (charArrayOne[i] != ' '){
				List_Of_Array_One.add(charArrayOne[i]);
			}
		}
		for (int j = 0; j < charArrayTwo.length; j++){
			if (charArrayTwo[j] != ' '){
				List_Of_Array_Two.add(charArrayTwo[j]);
			}
		}
	}
	
	private static boolean stringsAreAngram(ArrayList<Character> List_Of_Array_One, ArrayList<Character> List_Of_Array_Two){
		Collections.sort(List_Of_Array_One);
		Collections.sort(List_Of_Array_Two);
		return List_Of_Array_One.equals(List_Of_Array_Two);
	}
}
